package com.longcai.controller.nearby;


import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.longcai.bean.ApiResult;
import com.longcai.service.nearby.ClyjNearbyPackageService;
import com.longcai.util.StringUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/****
 * 团购店铺
 * @author kh
 *
 */
@Controller
@RequestMapping("/clyjNearbyPackage")
public class ClyjNearbyPackageController {
	
	private static Logger logger = LoggerFactory.getLogger(ClyjNearbyPackageController.class);
	@Autowired
	private ClyjNearbyPackageService  clyjNearbyPackageService;
	/**
     * 店铺团购列表
     *
     * @param params
     * @return
     */
    @RequestMapping("/getNearbyPackageList")
    @ResponseBody
    public ApiResult<?> getNearbyPackageList(@RequestBody JSONObject params) {
        String shopsid = params.getString("shopsid");//商铺Id
        if (StringUtils.isEmpty(shopsid)) {
        	logger.error(" 团购店铺详情-------------参数非法------------"+"shopsid:"+shopsid);
        	return ApiResult.fail("查询失败");
        }
        return this.clyjNearbyPackageService.getNearbyPackageList(shopsid);
    }
    
    /**
     * 店铺团购列表
     *
     * @param params
     * @return
     */
    @RequestMapping("/getNearbyPackage")
    @ResponseBody
    public ApiResult<?> getNearbyPackage(@RequestBody JSONObject params) {
        String shopsid = params.getString("shopsid");//商铺Id
        String packageId = params.getString("packageId");//套餐id（团购Id）
        if (StringUtils.isEmpty(shopsid)||StringUtils.isEmpty(packageId)) {
        	logger.error(" 团购店铺详情-------------参数非法------------"
                           +"shopsid:"+shopsid+"----------------"
                           +"packageId:"+packageId+"----------------");
        	return ApiResult.fail("查询失败");
        }
        return this.clyjNearbyPackageService.getNearbyPackage(shopsid,packageId);
    }
}

